﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CountDownProject
{
    public partial class Main : Form
    {

       string beginMinute="29";
        string beginSecond = "60";

        public Main()
        {
            InitializeComponent();

            timer1.Stop();
        }


        private void timer1_Tick(object sender, EventArgs e)
        { 
            BeginTimer(textBox2, textBox1, label8, timer1);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            BeginButton(textBox2, textBox1, label8, timer1); 
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void button2_Click_1(object sender, EventArgs e)
        { 
            BeginButton(textBox3, textBox4, label10, timer2); 
        }

        private void timer2_Tick(object sender, EventArgs e)
        { 
            BeginTimer(textBox3, textBox4, label10, timer2);

        }

        private void button3_Click(object sender, EventArgs e)
        { 
            BeginButton(textBox5, textBox6, label12, timer3); 
        }

        private void timer3_Tick(object sender, EventArgs e)
        { 
            BeginTimer(textBox5, textBox6, label12, timer3); 
        }

        private void button4_Click(object sender, EventArgs e)
        { 
            BeginButton(textBox7, textBox8, label14, timer4); 
        }

        private void timer4_Tick(object sender, EventArgs e)
        { 
            BeginTimer(textBox7, textBox8, label14, timer4);
        }

        private void button5_Click(object sender, EventArgs e)
        { 
            BeginButton(textBox9, textBox10, label16, timer5); 
        }

        private void timer5_Tick(object sender, EventArgs e)
        {
            BeginTimer(textBox9, textBox10, label16, timer5); 
        }

        private void button6_Click(object sender, EventArgs e)
        {
            BeginButton(textBox11, textBox12, label18, timer6);
        }

        private void timer6_Tick(object sender, EventArgs e)
        {
            BeginTimer(textBox11, textBox12, label18, timer6);
        }

        private void BeginTimer(TextBox txtSencod, TextBox txtMinute,Label lable,Timer timer)
        {
            int second = int.Parse(txtSencod.Text);
            int minute = int.Parse(txtMinute.Text);

            txtSencod.Text = (second - 1).ToString();

            if (second == 0 && minute == 0)
            {
                lable.Text = "已出现";
                timer.Stop();
            }
            else if (second == 0 && minute > 0)
            {
                txtMinute.Text = (minute - 1).ToString();
                txtSencod.Text = "60";
            }
        }


        private  void BeginButton(TextBox txtSencod, TextBox txtMinute, Label lable, Timer timer)
        {
            txtMinute.Text =  beginMinute;
            txtSencod.Text = beginSecond;
            timer.Start();
            timer.Interval = 1000;
            lable.Text = "";
        }

        private void button7_Click(object sender, EventArgs e)
        {
            BeginButton(textBox13, textBox14, label20, timer7);

        }

        private void timer7_Tick(object sender, EventArgs e)
        {
            BeginTimer(textBox13, textBox14, label20, timer7);
        }

        private void label14_Click(object sender, EventArgs e)
        {

        }
    }
}
